/**
 * 走势
 * @type {{aggregateWaters: number, summarySteams: number, aggregateGass: number, costPools: number, airCollectionss: number, aggregateCoolings: number, aggregateElectricitys: number, collectChart: number}}
 */
var energyDevId = {
    "collectChart": {
        id:10337,
        name:"能耗走势(碳排)",
        unitTotal:"T",
        unitSingle:"kg/辆"
    },//碳排
    "costPools": {
        id:10327,
        name:"能耗走势(成本)",
        unitTotal:"千元",
        unitSingle:"元/辆"
    },//成本
    "summarySteams": {
        id:10323,
        name:"能耗走势(蒸汽)",
        unitTotal:"T",
        unitSingle:"T/辆"
    },//蒸汽
    "aggregateWaters": {
        id:10316,
        name:"能耗走势(用水)",
        unitTotal:"T",
        unitSingle:"T/辆"
    },//用水
    "aggregateGass": {
        id:10309,
        name:"能耗走势(燃气)",
        unitTotal:"Nm³",
        unitSingle:"Nm³/辆"
    },//燃气
    "aggregateElectricitys": {
        id:10302,
        name:"能耗走势(用电)",
        unitTotal:"kwh",
        unitSingle:"kwh/辆"
    },//用电
    "airCollectionss": {
        id:10293,
        name:"能耗走势(空气)",
        unitTotal:"m³",
        unitSingle:"m³/辆"
    },//空气
    "aggregateCoolings": {
        id:10285,
        name:"能耗走势(冷量)",
        unitTotal:"Kcal",
        unitSingle:"Kcal/辆"
    }//冷量
};
dev.action = function(resp,param){

    var spaceName = param.workSpaceName;
    var name = param.name;
    // 获取能源架构ID
    var workSpace = iot.getEnergySpaceId(spaceName,name);
    if (workSpace === -1){
        resp.setJsData("找不到数据");
        return;
    }

    var param= {
       id:energyDevId[name].id,
       time: param.time,
       selectType: param.selectType,
       workSpace:workSpace,
       workSpaceName: spaceName
    }

    // 调用其他设备的 js 逻辑获取数据
    var result = iot.bridgeOtherJsResult(JSON.stringify(param));
    result.jsData.title = energyDevId[name].name;

    var yLeft = result.jsData.yLeft;
    var yRight = result.jsData.yRight;
    if (param.selectType === "single"){
        result.jsData.unit = energyDevId[name].unitSingle;//单位
    } else if (name === "collectChart" || name === "costPools") {
        result.jsData.unit = energyDevId[name].unitTotal;

        for (var index in yLeft) {
            yLeft[index] = decimalRetainRule(yLeft[index] / 1000);
        }

        result.jsData.yLeft = yLeft;

        for (var index in yRight) {
            yRight[index] = decimalRetainRule(yRight[index] / 1000);
        }

        result.jsData.yLeft = yLeft;
        result.jsData.yRight = yRight;
    } else {
        result.jsData.unit = energyDevId[name].unitTotal;
    }



    
    resp.setJsData(result.jsData);
}